home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
hity wydania
/
trueSpace 7.6
/
tS761B8Std.exe
/
{app}
/
Scripts
/
D3D
/
RsD3DZBufferFill.fx
< prev
next >
Wrap
Text File
|
2008-06-10
|
3KB
|
119 lines
//----------------------------------------------------------------------
//Z-buffer fill-rendering
//
//Author - Michal Valient
//Copyright (C) 2004-2008 Caligari corporation
//
//----------------------------------------------------------------------
uniform float4x4 mToClip;
#ifdef RsShaderHWSKINNING
#define SKIN_INDEX_SHIFT 0.001960784313725490196078431372549f
#define RTD3DMESH_MAXIMUM_BONE_COUNT 64
float4x3 RsD3DMaterialFromME_mSkinMatrices[RTD3DMESH_MAXIMUM_BONE_COUNT];
#endif //RsShaderHWSKINNING
struct VS_MATPOINT_IN {
float4 vPosition : POSITION; //position in object space
};
typedef struct {
float4 vPosition : POSITION; //position in object space
float4 cColor : COLOR;
} VS_MATPOINT_OUT;
VS_MATPOINT_OUT VS_CMaterialZFill(in VS_MATPOINT_IN input
#ifdef RsShaderHWSKINNING
, in float4 D3_vInputBlendIndices : BLENDINDICES
, in float4 D3_cInputBlendWeight : BLENDWEIGHT
#endif //RsShaderHWSKINNING
)
{
float4 local_vertex_position;
#ifdef RsShaderHWSKINNING
float3 tmp_position = 0;
//Get the blend weights
float4 blend_weights = (255.0f/127.0f)*D3_cInputBlendWeight - (128.0f / 127.0f);
float4 blend_indices = D3_vInputBlendIndices * 255.0f + SKIN_INDEX_SHIFT;
/// Skin it!
for (int bone_idx = 0; bone_idx<4; bone_idx++)
{
int matrix_idx = (int)blend_indices[bone_idx];
float weight = blend_weights[bone_idx];
float3 bone_position = weight*mul(input.vPosition, RsD3DMaterialFromME_mSkinMatrices[matrix_idx]);
tmp_position += bone_position;
}
local_vertex_position.xyz = tmp_position.xyz;
local_vertex_position.w = 1.0f;
#else
local_vertex_position = input.vPosition;
#endif //RsShaderHWSKINNING
VS_MATPOINT_OUT output;
output.vPosition = mul(local_vertex_position, mToClip); //vertex clip position
output.cColor = 0;
return output;
}
vertexshader VS_ZBufferFill = compile vs_2_0 VS_CMaterialZFill();
technique T_ZBufferFill_Bias
{
pass P0
{
VertexShader = (VS_ZBufferFill);
PixelShader = NULL;
AlphaBlendEnable = false;
ColorWriteEnable = 0;
ZEnable = true;
ZFunc = LESSEQUAL;
ZWriteEnable = true;
Lighting = false;
ShadeMode = FLAT;
FillMode = SOLID;
CullMode = NONE;
DepthBias = (1.0f/65536.0f);
}
}
technique T_ZBufferFill_NoBias
{
pass P0
{
VertexShader = (VS_ZBufferFill);
PixelShader = NULL;
AlphaBlendEnable = false;
ColorWriteEnable = 0;
ZEnable = true;
ZFunc = LESSEQUAL;
ZWriteEnable = true;
Lighting = false;
ShadeMode = FLAT;
FillMode = SOLID;
CullMode = CW;
}
}